package com.shenjun.union.controller;

import com.shenjun.union.servers.HelloClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("send")
public class SendMsgController {

    @Autowired
    private HelloClient helloClient;

    @GetMapping("/send001")
    public String send001(@RequestParam(value = "msg") String msg) throws InterruptedException {
        System.out.println(msg);

        for (int i = 0; i < 20; i++) {
            String umsg = "[银联发消息" + i + "]";
            Thread.sleep(1000);
            helloClient.writeAndFlush(umsg);
        }

        return "88";
    }
}
